package com.controller.library;

import java.io.UnsupportedEncodingException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bean.library.Paper;

public class TCheckPaperContentListServlet extends HttpServlet{

	/**
	 * 
	 */
	private static final long serialVersionUID = 3749581256725794274L;
	public void doGet(HttpServletRequest request,HttpServletResponse response){
		try {
			request.setCharacterEncoding("utf-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		Paper paper = (Paper)request.getSession().getAttribute("paper");
		int pageNum = Integer.parseInt(request.getParameter("submit_page_num"));
		Paper partialPaper = new Paper();
		partialPaper.setPaperName(paper.getPaperName());
		partialPaper.setStartIndex(pageNum - 1);
		partialPaper.setSubjectList(paper.getSubjectList((pageNum-1)*10, 10));
		request.getSession().setAttribute("partialPaper", partialPaper);
		if(request.getSession().getAttribute("selectedCourseId")!=null){
			try {
				response.sendRedirect("/Exam1/teacher/t_page/t_paper_content.jsp?"+request.getQueryString());
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}
